<?php

  /**
	 * Definicion de Schema con el cual se basará el ORM para crear los Class y Web Services.
   *
   * @category cormo
   * @package Core
   * @author Germán Dario Peraferrer <gperaferrer@gmail.com>
   * @copyright Copyright (c) 2007 Germán Dario Peraferrer - Beetec
   * @version 1.0 Beta
   * @license http://www.opensource.org/licenses/bsd-license.php New BSD License
   * @link http://code.google.com/p/cormoframework/
   * @link http://www.beetec.com.ar
	 */

    abstract class Cormo {

        static private $ormSchema = array();

        function  __construct() {

        }

        /**
         * Devuelve el Schema de uso interno que será utilizado por el Generator
         *
         * @return array Definicion del Schema de uso interno que será utilizado por Generator
         */
        public static function getOrmSchema() {
            return self::$ormSchema;
        }

        /**
         * Definie el Array con la configuracion de Schema del ORM.
         *
         * @global array $CORMO
         */
        public static function generateOrmSchema() {
            global $CORMO;
            $CORMO = self::getOrmSchema();
        }

        /**
         * Define un DataSource en el Schema del ORM.
         *
         * @param string $nameDataSource
         * @param string $type mysql, mssql, pgsql, ibm, oci, odbc, sqlite, firebird, informix, 4D
         * @param string $host
         * @param string $dbname
         * @param string $user
         * @param string $password
         * @param boolean $persistent
         */
        public static function addDataSource($nameDataSource, $type, $host, $dbname, $user='', $password='', $persistent=true) {
            self::$ormSchema["cnx_".$nameDataSource] = array ("type" => $type,
                                                              "host" => $host,
                                                              "dbname" => $dbname,
                                                              "user" => $user,
                                                              "password" => $password,
                                                              "persistent" => $persistent);
        }

        /**
         * Define un Object proxy Web Services en el Schema del ORM
         *
         * @param string $nameWebServices Nombre del Object Proxy a utilizar en el Modelo
         * @param string $url
         * @param boolean $isWSDL
         * @param string $proxyHost
         * @param string $proxyPort
         * @param string $proxyUserName
         * @param string $proxyPassword
         * @param string $timeOut
         * @param string $responseTimeOut
         */
        public static function addWebServices($nameWebServices, $url, $isWSDL=true, $proxyHost='', $proxyPort='', $proxyUserName='', $proxyPassword='', $timeOut=0, $responseTimeOut=30) {
        	self::$ormSchema["wsdl_".$nameWebServices] = array("Url" => $url,
                                                               "isWSDL" => $isWSDL,
                                                               "ProxyHost" => $proxyHost,
                                                               "ProxyPort" => $proxyPort,
                                                               "ProxyUserName" => $proxyUserName,
                                                               "ProxyPassword" => $proxyPassword,
                                                               "TimeOut" => $timeOut,
                                                               "ResponseTimeOut" => $responseTimeOut,
                                                               "ObjectName" => $nameWebServices );
        }

        /**
         * Define el Object que será utilizado en el Schema por el ORM
         *
         * @param string $nameObject
         * @param string $nameDataSource
         * @param string $tableName
         * @param string $key
         * @param array $fields
         * @param array $tableAssociate
         * @param array $defaultValues
         * @param array $propertyNotCompare
         * @param array $functionsSQL
         */
        public static function addObject($nameObject, $nameDataSource, $tableName, $key, $fields=array(), $tableAssociate=array(), $defaultValues=array(), $propertyNotCompare=array(), $functionsSQL=array()) {
			 self::$ormSchema["orm_".$nameObject] = array("Fields" => $fields,
                                                          "TableName" => $tableName,
                                                          "Key" => $key,
                                                          "TableAssociate" => $tableAssociate,
                                                          "ObjectName" => $nameObject,
                                                          "DefaultValues" => $defaultValues,
                                                          "PropertyNotCompare" => $propertyNotCompare,
                                                          "Connection" => "cnx_".$nameDataSource,
                                                          "FunctionsSQL" => $functionsSQL);
        }

    }
?>
